package com.yc.pre.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.ParseException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

/**
 * @ClassName HttpUtils
 * @Description http远程请求
 * @Date 2020/12/02 17:27:50
 * @Created by ccc-j
 * @email ccc-ju@outlook.com
 */
public class HttpUtils {

    /**
     * 发送GET请求
     *
     * @param url
     *            目的地址
     * @param parameters
     *            请求参数，Map类型。
     * @return 远程响应结果
     */
    public static String sendGet(String url, Map<String, String> parameters) {
        String result="";
        BufferedReader in = null;// 读取响应输入流
        StringBuffer sb = new StringBuffer();// 存储参数
        String params = "";// 编码之后的参数
        try {
            // 编码请求参数
            if(parameters.size()==1){
                for(String name:parameters.keySet()){
                    sb.append(name).append("=").append(
                            java.net.URLEncoder.encode(parameters.get(name),
                                    "UTF-8"));
                }
                params=sb.toString();
            }else{
                for (String name : parameters.keySet()) {
                    sb.append(name).append("=").append(
                            java.net.URLEncoder.encode(parameters.get(name),
                                    "UTF-8")).append("&");
                }
                String temp_params = sb.toString();
                params = temp_params.substring(0, temp_params.length() - 1);
            }
            String full_url = url + "?" + params;
            System.out.println(full_url);
            // 创建URL对象
            java.net.URL connURL = new java.net.URL(full_url);
            // 打开URL连接
            java.net.HttpURLConnection httpConn = (java.net.HttpURLConnection) connURL
                    .openConnection();
            // 设置通用属性
            httpConn.setRequestProperty("Accept", "*/*");
            httpConn.setRequestProperty("Connection", "Keep-Alive");
            httpConn.setRequestProperty("User-Agent",
                    "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
            // 建立实际的连接
            httpConn.connect();
            // 响应头部获取
            Map<String, List<String>> headers = httpConn.getHeaderFields();
            // 遍历所有的响应头字段
            for (String key : headers.keySet()) {
                System.out.println(key + "\t：\t" + headers.get(key));
            }
            // 定义BufferedReader输入流来读取URL的响应,并设置编码方式
            in = new BufferedReader(new InputStreamReader(httpConn
                    .getInputStream(), "UTF-8"));
            String line;
            // 读取返回的内容
            while ((line = in.readLine()) != null) {
                result += line;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
            try {
                if (in != null) {
                    in.close();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        return result ;
    }

    /**
     * 发送POST请求
     *
     * @param url
     *            目的地址
     * @param parameters
     *            请求参数，Map类型。
     * @return 远程响应结果
     */
    public static String sendPost(String url, Map<String, String> parameters) {
        String result = "";// 返回的结果
        BufferedReader in = null;// 读取响应输入流
        PrintWriter out = null;
        StringBuffer sb = new StringBuffer();// 处理请求参数
        String params = "";// 编码之后的参数
        try {
            // 编码请求参数
            if (parameters.size() == 1) {
                for (String name : parameters.keySet()) {
                    sb.append(name).append("=").append(
                            java.net.URLEncoder.encode(parameters.get(name),
                                    "UTF-8"));
                }
                params = sb.toString();
            } else {
                for (String name : parameters.keySet()) {
                    sb.append(name).append("=").append(
                            java.net.URLEncoder.encode(parameters.get(name),
                                    "UTF-8")).append("&");
                }
                String temp_params = sb.toString();
                params = temp_params.substring(0, temp_params.length() - 1);
            }
            // 创建URL对象
            java.net.URL connURL = new java.net.URL(url);
            // 打开URL连接
            java.net.HttpURLConnection httpConn = (java.net.HttpURLConnection) connURL
                    .openConnection();
            // 设置通用属性
            httpConn.setRequestProperty("Accept", "*/*");
            httpConn.setRequestProperty("Connection", "Keep-Alive");
            httpConn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
            httpConn.setRequestProperty("token", "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxMzQxMzU4NzYzNDk5NTg5NjMyIiwic3ViIjoiMTgyMzY0OTc4NDUiLCJpc3MiOiJhZG1pbiIsImlhdCI6MTYwODg4NTQ5MywiZXhwIjoxNjA4OTcxODkzfQ.Ryrmn119hvTLl3Ei-DT999Sjoe9_qRicewYOg2LFvCw");
            // 设置POST方式
            httpConn.setDoInput(true);
            httpConn.setDoOutput(true);
            // 获取HttpURLConnection对象对应的输出流
            out = new PrintWriter(httpConn.getOutputStream());
            // 发送请求参数
            out.write(params);
            // flush输出流的缓冲
            out.flush();
            // 定义BufferedReader输入流来读取URL的响应，设置编码方式
            in = new BufferedReader(new InputStreamReader(httpConn
                    .getInputStream(), "UTF-8"));
            String line;
            // 读取返回的内容
            while ((line = in.readLine()) != null) {
                result += line;
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (out != null) {
                    out.close();
                }
                if (in != null) {
                    in.close();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        return result;
    }

    /**
     * 发送post请求
     * @param url  路径
     * @param jsonObject  参数(json类型)
     * @param encoding 编码格式
     * @param headerParam header中存放参数
     * @return
     * @throws ParseException
     * @throws IOException
     */
    public static String sendPostJson(String url, JSONObject jsonObject, String encoding, Map<String, String> headerParam) throws ParseException, IOException{
        String body = "";

        //创建httpclient对象
        CloseableHttpClient client = HttpClients.createDefault();
        //创建post方式请求对象
        HttpPost httpPost = new HttpPost(url);

        //装填参数
        StringEntity s = new StringEntity(jsonObject.toString(), "utf-8");
        s.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,
                "application/json"));
        //设置参数到请求对象中
        httpPost.setEntity(s);
        System.out.println("请求地址："+url);
//        System.out.println("请求参数："+nvps.toString());

        //设置header信息
        //指定报文头【Content-type】、【User-Agent】
//        httpPost.setHeader("Content-type", "application/x-www-form-urlencoded");
        httpPost.setHeader("Content-type", "application/json");
        httpPost.setHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
        if(null != headerParam || headerParam.size() != 0){
            for(Map.Entry<String, String> entry  : headerParam.entrySet()){
                httpPost.setHeader(entry.getKey(), headerParam.get(entry.getKey()));
            }
        }

        //执行请求操作，并拿到结果（同步阻塞）
        CloseableHttpResponse response = client.execute(httpPost);
        //获取结果实体
        HttpEntity entity = response.getEntity();
        if (entity != null) {
            //按指定编码转换结果实体为String类型
            body = EntityUtils.toString(entity, encoding);
        }
        EntityUtils.consume(entity);
        //释放链接
        response.close();
        return body;
    }

    /**
     * 主函数，测试请求
     *
     * @param args
     */
    public static void main(String[] args) {
        /*Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("loginType", "0");
        parameters.put("phone", "17630829902");
        parameters.put("phoneCode", "000000");
        String result = sendPost("http://172.16.151.210:10002/service/auth/login", parameters);
        System.out.println(result);*/
        /*Map<String, String> map = new HashMap<>();
        map.put("hhh ", "123");
        for(Map.Entry<String, String> entry  : map.entrySet()){
            System.out.println(entry.getKey() + ":" + map.get(entry.getKey()));
        }*/
        /*JSONObject jsonObject = new JSONObject();
        jsonObject.put("loginType", 0);
        jsonObject.put("phone", "17630829902");
        jsonObject.put("phoneCode", "000000");
        try {
            String res = sendPostJson("http://172.16.151.210:10002/service/auth/login", jsonObject, "UTF-8", new HashMap<String, String>());
            System.out.println(res);
        } catch (IOException e) {
            e.printStackTrace();
        }*/
        // 查询工商库信息
        /*String url = "http://10.0.132.12:9292/common/getJson/1001?tokenId=5802";
        Map<String, String> map = new HashMap<>();
        map.put("X-AURORA-TOKEN", "8ee0be299ed2e8c9b09ee32acbb32f5aff56587e");
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("name", "杭州源诚科技有限公司");
        jsonObject.put("type", "direct");
        try {
            String res = sendPostJson(url, jsonObject, "UTF-8", map);
            System.out.println(res);
        } catch (IOException e) {
            e.printStackTrace();
        }*/
        String str = "{\"result\":\"{\"error_code\":300000,\"reason\":\"ok\",\"result\":{\"id\":3065156814,\"base\":\"zj\",\"name\":\"杭州源诚科技有限公司\",\"legalPersonName\":\"徐升\",\"legalPersonType\":1,\"regNumber\":\"330108000354407\",\"industry\":\"软件和信息技术服务业\",\"companyOrgType\":\"有限责任公司(自然人投资或控股)\",\"regLocation\":\"浙江省杭州市西湖区万塘路317号华星世纪大楼603、605室\",\"estiblishTime\":\"2017-06-06\",\"fromTime\":\"2017-06-06\",\"toTime\":\"9999-09-09\",\"businessScope\":\"技术开发、技术服务、技术咨询、成果转让：计算机软硬件、数据处理技术；服务：经济信息咨询（依法须经批准的项目，经相关部门批准后方可开展经营活动）\",\"approvedTime\":\"2020-03-11\",\"regStatus\":\"存续\",\"regCapital\":\"500万人民币\",\"regInstitute\":\"杭州市高新区（滨江）市场监督管理局\",\"orgNumber\":\"MA28TQ2Y8\",\"creditCode\":\"91330108MA28TQ2Y8T\",\"property3\":null,\"updatetime\":\"2020-12-23 06:21:37.43544\",\"companyId\":null,\"taxNumber\":null,\"email\":\"fc@yczcjk.com\",\"website\":\"www.yczcjk.com\",\"phoneNumber\":\"0571-81182249\",\"revokeDate\":null,\"revokeReason\":null,\"cancelDate\":null,\"cancelReason\":null,\"staffList\":[{\"id\":1979401840,\"name\":\"李佳\",\"logo\":null,\"type\":2,\"staffTypeName\":\"监事\",\"typeJoin\":[\"监事\"]},{\"id\":1939530492,\"name\":\"徐升\",\"logo\":null,\"type\":2,\"staffTypeName\":\"执行董事兼总经理\",\"typeJoin\":[\"执行董事兼总经理\"]}],\"abnormalList\":null,\"illegalList\":null,\"punishList\":null,\"checkList\":null,\"licenseList\":null,\"liquidatingInfo\":null,\"equityList\":null,\"branchList\":null,\"judicialList\":null,\"briefCancel\":null,\"iprPledgeList\":null,\"mortList\":null,\"reportList\":[{\"id\":2643228300,\"reportYear\":\"2017\",\"companyName\":\"杭州源诚科技有限公司\",\"creditCode\":\"91330108MA28TQ2Y8T\",\"regNumber\":null,\"phoneNumber\":\"0571-81182249\",\"postcode\":\"310012\",\"postalAddress\":\"浙江省杭州市西湖区翠苑街道文二路391号西湖国际科技大厦5号楼4层422室-25\",\"email\":\"hr@yczcjk.com\",\"manageState\":\"正常开业\",\"employeeNum\":\"企业选择不公示\",\"operatorName\":null,\"totalAssets\":\"企业选择不公示\",\"totalEquity\":\"企业选择不公示\",\"totalSales\":\"企业选择不公示\",\"totalProfit\":\"企业选择不公示\",\"primeBusProfit\":\"企业选择不公示\",\"retainedProfit\":\"企业选择不公示\",\"totalTax\":\"企业选择不公示\",\"totalLiability\":\"企业选择不公示\",\"changeList\":null,\"equityChangeList\":null,\"guaranteeList\":null,\"outBoundList\":null,\"shareHolderList\":[{\"investorName\":\"王琼琼\",\"subscribeAmount\":\"21.25万元\",\"subscribeTime\":\"2047-05-31\",\"subscribeType\":\"货币\",\"paidAmount\":\"0万元\",\"paidTime\":null,\"paidType\":\"\"},{\"investorName\":\"沈超\",\"subscribeAmount\":\"21.25万元\",\"subscribeTime\":\"2047-05-31\",\"subscribeType\":\"货币\",\"paidAmount\":\"0万元\",\"paidTime\":null,\"paidType\":\"\"},{\"investorName\":\"徐升\",\"subscribeAmount\":\"279.5万元\",\"subscribeTime\":\"2047-05-31\",\"subscribeType\":\"货币\",\"paidAmount\":\"0万元\",\"paidTime\":null,\"paidType\":\"\"},{\"investorName\":\"汪丹\",\"subscribeAmount\":\"25万元\",\"subscribeTime\":\"2047-05-31\",\"subscribeType\":\"货币\",\"paidAmount\":\"0万元\",\"paidTime\":null,\"paidType\":\"\"},{\"investorName\":\"李伟刚\",\"subscribeAmount\":\"153万元\",\"subscribeTime\":\"2047-05-31\",\"subscribeType\":\"货币\",\"paidAmount\":\"0万元\",\"paidTime\":null,\"paidType\":\"\"}],\"webList\":null,\"socialList\":[{\"endowmentInsurance\":\"6人\",\"unemploymentInsurance\":\"6人\",\"medicalInsurance\":\"6人\",\"employmentInjuryInsurance\":\"6人\",\"maternityInsurance\":\"6人\",\"endowmentInsuranceBase\":\"企业选择不公示\",\"unemploymentInsuranceBase\":\"企业选择不公示\",\"medicalInsuranceBase\":\"企业选择不公示\",\"maternityInsuranceBase\":\"企业选择不公示\",\"endowmentInsurancePayAmount\":\"企业选择不公示\",\"unemploymentInsurancePayAmount\":\"企业选择不公示\",\"medicalInsurancePayAmount\":\"企业选择不公示\",\"employmentInjuryInsurancePayAmount\":\"企业选择不公示\",\"maternityInsurancePayAmount\":\"企业选择不公示\",\"endowmentInsuranceOweAmount\":\"企业选择不公示\",\"unemploymentInsuranceOweAmount\":\"企业选择不公示\",\"medicalInsuranceOweAmount\":\"企业选择不公示\",\"employmentInjuryInsuranceOweAmount\":\"企业选择不公示\",\"maternityInsuranceOweAmount\":\"企业选择不公示\"}]},{\"id\":2928015701,\"reportYear\":\"2018\",\"companyName\":\"杭州源诚科技有限公司\",\"creditCode\":\"91330108MA28TQ2Y8T\",\"regNumber\":null,\"phoneNumber\":\"057181182249\",\"postcode\":\"310012\",\"postalAddress\":\"浙江省杭州市西湖区文二路391号西湖国际科技大厦5号楼4层422室-25\",\"email\":\"fc@yczcjk.com\",\"manageState\":\"正常开业\",\"employeeNum\":\"企业选择不公示\",\"operatorName\":null,\"totalAssets\":\"企业选择不公示\",\"totalEquity\":\"企业选择不公示\",\"totalSales\":\"企业选择不公示\",\"totalProfit\":\"企业选择不公示\",\"primeBusProfit\":\"企业选择不公示\",\"retainedProfit\":\"企业选择不公示\",\"totalTax\":\"企业选择不公示\",\"totalLiability\":\"企业选择不公示\",\"changeList\":null,\"equityChangeList\":null,\"guaranteeList\":null,\"outBoundList\":null,\"shareHolderList\":[{\"investorName\":\"汪丹\",\"subscribeAmount\":\"25万元\",\"subscribeTime\":\"2047-05-31\",\"subscribeType\":\"货币\",\"paidAmount\":\"0万元\",\"paidTime\":null,\"paidType\":\"\"},{\"investorName\":\"李伟刚\",\"subscribeAmount\":\"153万元\",\"subscribeTime\":\"2047-05-31\",\"subscribeType\":\"货币\",\"paidAmount\":\"0万元\",\"paidTime\":null,\"paidType\":\"\"},{\"investorName\":\"王琼琼\",\"subscribeAmount\":\"21.25万元\",\"subscribeTime\":\"2047-05-31\",\"subscribeType\":\"货币\",\"paidAmount\":\"0万元\",\"paidTime\":null,\"paidType\":\"\"},{\"investorName\":\"徐升\",\"subscribeAmount\":\"279.5万元\",\"subscribeTime\":\"2047-05-31\",\"subscribeType\":\"货币\",\"paidAmount\":\"0万元\",\"paidTime\":null,\"paidType\":\"\"},{\"investorName\":\"沈超\",\"subscribeAmount\":\"21.25万元\",\"subscribeTime\":\"2047-05-31\",\"subscribeType\":\"货币\",\"paidAmount\":\"0万元\",\"paidTime\":null,\"paidType\":\"\"}],\"webList\":null,\"socialList\":[{\"endowmentInsurance\":\"20人\",\"unemploymentInsurance\":\"20人\",\"medicalInsurance\":\"20人\",\"employmentInjuryInsurance\":\"20人\",\"maternityInsurance\":\"20人\",\"endowmentInsuranceBase\":\"企业选择不公示\",\"unemploymentInsuranceBase\":\"企业选择不公示\",\"medicalInsuranceBase\":\"企业选择不公示\",\"maternityInsuranceBase\":\"企业选择不公示\",\"endowmentInsurancePayAmount\":\"企业选择不公示\",\"unemploymentInsurancePayAmount\":\"企业选择不公示\",\"medicalInsurancePayAmount\":\"企业选择不公示\",\"employmentInjuryInsurancePayAmount\":\"企业选择不公示\",\"maternityInsurancePayAmount\":\"企业选择不公示\",\"endowmentInsuranceOweAmount\":\"企业选择不公示\",\"unemploymentInsuranceOweAmount\":\"企业选择不公示\",\"medicalInsuranceOweAmount\":\"企业选择不公示\",\"employmentInjuryInsuranceOweAmount\":\"企业选择不公示\",\"maternityInsuranceOweAmount\":\"企业选择不公示\"}]},{\"id\":2975361058,\"reportYear\":\"2019\",\"companyName\":\"杭州源诚科技有限公司\",\"creditCode\":\"91330108MA28TQ2Y8T\",\"regNumber\":null,\"phoneNumber\":\"0571-81182249\",\"postcode\":\"310012\",\"postalAddress\":\"浙江省杭州市西湖区翠苑街道万塘路317号华星世纪大楼603、605室\",\"email\":\"fc@yczcjk.com\",\"manageState\":\"正常开业\",\"employeeNum\":\"企业选择不公示\",\"operatorName\":null,\"totalAssets\":\"企业选择不公示\",\"totalEquity\":\"企业选择不公示\",\"totalSales\":\"企业选择不公示\",\"totalProfit\":\"企业选择不公示\",\"primeBusProfit\":\"企业选择不公示\",\"retainedProfit\":\"企业选择不公示\",\"totalTax\":\"企业选择不公示\",\"totalLiability\":\"企业选择不公示\",\"changeList\":null,\"equityChangeList\":[{\"investorName\":\"王琼琼\",\"ratioBefore\":\"4.25%\",\"ratioAfter\":\"4.44%\",\"changeTime\":\"2019-11-05\"},{\"investorName\":\"杭州源数诚科技合伙企业（有限合伙）\",\"ratioBefore\":\"0%\",\"ratioAfter\":\"25%\",\"changeTime\":\"2019-11-05\"},{\"investorName\":\"徐升\",\"ratioBefore\":\"55.9%\",\"ratioAfter\":\"70.56%\",\"changeTime\":\"2019-11-05\"}],\"guaranteeList\":null,\"outBoundList\":null,\"shareHolderList\":[{\"investorName\":\"王琼琼\",\"subscribeAmount\":\"22.191万元\",\"subscribeTime\":\"2047-05-31\",\"subscribeType\":\"货币\",\"paidAmount\":\"0万元\",\"paidTime\":null,\"paidType\":\"\"},{\"investorName\":\"杭州源数诚科技合伙企业（有限合伙）\",\"subscribeAmount\":\"125万元\",\"subscribeTime\":\"2047-05-31\",\"subscribeType\":\"货币\",\"paidAmount\":\"0万元\",\"paidTime\":null,\"paidType\":\"\"},{\"investorName\":\"徐升\",\"subscribeAmount\":\"352.809万元\",\"subscribeTime\":\"2047-05-31\",\"subscribeType\":\"货币\",\"paidAmount\":\"0万元\",\"paidTime\":null,\"paidType\":\"\"}],\"webList\":null,\"socialList\":[{\"endowmentInsurance\":\"42人\",\"unemploymentInsurance\":\"42人\",\"medicalInsurance\":\"42人\",\"employmentInjuryInsurance\":\"42人\",\"maternityInsurance\":\"42人\",\"endowmentInsuranceBase\":\"企业选择不公示\",\"unemploymentInsuranceBase\":\"企业选择不公示\",\"medicalInsuranceBase\":\"企业选择不公示\",\"maternityInsuranceBase\":\"企业选择不公示\",\"endowmentInsurancePayAmount\":\"企业选择不公示\",\"unemploymentInsurancePayAmount\":\"企业选择不公示\",\"medicalInsurancePayAmount\":\"企业选择不公示\",\"employmentInjuryInsurancePayAmount\":\"企业选择不公示\",\"maternityInsurancePayAmount\":\"企业选择不公示\",\"endowmentInsuranceOweAmount\":\"企业选择不公示\",\"unemploymentInsuranceOweAmount\":\"企业选择不公示\",\"medicalInsuranceOweAmount\":\"企业选择不公示\",\"employmentInjuryInsuranceOweAmount\":\"企业选择不公示\",\"maternityInsuranceOweAmount\":\"企业选择不公示\"}]}],\"changeList\":[{\"id\":279520324,\"changeItem\":\"投资人(股权)备案\",\"changeTime\":\"2019-11-05\",\"contentBefore\":\"姓名: 徐升; 出资额: ***.*万; 百分比: **.*%;n姓名: 李伟刚; 出资额: ***万; 百分比: **.*%;n姓名: 汪丹; 出资额: **万; 百分比: *%;n姓名: 沈超; 出资额: **.**万; 百分比: *.**%;n姓名: 王琼琼; 出资额: **.**万; 百分比: *.**%;n\",\"contentAfter\":\"姓名: 徐升; 出资额: ***.***万; 百分比: **.****%;n企业名称: 杭州源数诚科技合伙企业（有限合伙）; 出资额: ***万; 百分比: **%;n姓名: 王琼琼; 出资额: **.***万; 百分比: *.****%;n\"},{\"id\":279520325,\"changeItem\":\"章程备案\",\"changeTime\":\"2019-11-05\",\"contentBefore\":\"\",\"contentAfter\":\"\"},{\"id\":282516611,\"changeItem\":\"高级管理人员备案\",\"changeTime\":\"2019-11-14\",\"contentBefore\":\"姓名: 徐升; 证件号码: ******************; 职位: 执行董事兼总经理;n姓名: 沈超; 证件号码: ******************; 职位: 监事;n\",\"contentAfter\":\"姓名: 徐升; 证件号码: ******************; 职位: 执行董事兼总经理;n姓名: 李佳; 证件号码: ******************; 职位: 监事;n\"},{\"id\":313513461,\"changeItem\":\"住所变更\",\"changeTime\":\"2020-03-11\",\"contentBefore\":\"浙江省杭州市西湖区文二路***号西湖国际科技大厦*号楼*层***室-**\",\"contentAfter\":\"浙江省杭州市西湖区万塘路***号华星世纪大楼***、***室\"},{\"id\":313513464,\"changeItem\":\"联系电话变更\",\"changeTime\":\"2020-03-11\",\"contentBefore\":\"***********\",\"contentAfter\":\"****-********\"}],\"investList\":null,\"shareHolderList\":[{\"id\":1939530492,\"logo\":null,\"name\":\"徐升\",\"alias\":null,\"type\":2,\"capital\":[{\"amomon\":\"352.809万人民币\",\"time\":\"2047-05-31\",\"percent\":\"70.56%\",\"paymet\":\"\"}],\"capitalActl\":null},{\"id\":3368427322,\"logo\":null,\"name\":\"杭州源数诚科技合伙企业（有限合伙）\",\"alias\":\"源数诚\",\"type\":1,\"capital\":[{\"amomon\":\"125万人民币\",\"time\":\"2047-05-31\",\"percent\":\"25.00%\",\"paymet\":\"\"}],\"capitalActl\":null},{\"id\":2074827492,\"logo\":null,\"name\":\"王琼琼\",\"alias\":null,\"type\":2,\"capital\":[{\"amomon\":\"22.191万人民币\",\"time\":\"2047-05-31\",\"percent\":\"4.44%\",\"paymet\":\"\"}],\"capitalActl\":null}]}}\",\"msg\":\"\",\"code\":0}";
        String substring = str.substring(11, str.length() - 20);
        JSONObject jsonObject = JSON.parseObject(substring);
        if(jsonObject.get("error_code").equals(300000)){
            System.out.println("输入有误!");
        }
        JSONObject result = (JSONObject) jsonObject.get("result");
        System.out.println(result.get("name"));
        System.out.println(result.get("creditCode"));
    }

}
